const Service = require("egg").Service;

class ShopInfoService extends Service {


    async query() {
        return await this.ctx.model.ShopInfo.find({});
    }

    // 修改
    async update(shopInfo) {
        return await this.ctx.model.ShopInfo.findOneAndUpdate(
            {_id: shopInfo._id},
            shopInfo
        );
    }

    async create(shopInfo) {
        return await this.ctx.model.ShopInfo.create(shopInfo);
    }

    async delete() {
        const ret = await this.ctx.model.ShopInfo.find({});
        let ids = [];
        ret.map(item => {
            ids.push(item._id.toString());
        });
        return await this.ctx.model.ShopInfo.remove({_id: {$in: ids}});
    }
}

module.exports = ShopInfoService;
